package com.flca.frw.util
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	
	import mx.core.Container;
	import mx.core.UIComponent;
	
	public class ViewUtils
	{
		public static function enableAllFields(aView:Container, 
			aFlag:Boolean, aExlude:Array = null) : void {
			
			for (var i:int=0; i < aView.numChildren; i++) {
				var obj:Object = aView.getChildAt(i);
				if (obj is Container) {
					enableAllFields(obj as Container, aFlag);
				} else if (obj is UIComponent) {
					if (!exludeThisField(obj as UIComponent, aExlude)) {
						(obj as UIComponent).enabled = aFlag;
					}
				}  
			}
		}
		
		private static function exludeThisField(aField:UIComponent, aArray:Array) : Boolean {
			if (aArray != null) {
				var id:String = aField.id;
				if (id != null) {
					for (var i:int=0; i < aArray.length; i++) {
						var excname:String = aArray[i] as String;
						if (excname == id) {
							return true;
						}
					}
				} 
			}
			return false;
		}
	}
}